﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ManageStudent.aspx.cs" Inherits="Presentation.ManageStudent"  MasterPageFile="~/Site.Master"%>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <div>
     <asp:Panel runat="server" ID="PanelCreateStudent">
     <script type="text/javascript">
         function GotoStudentMainPage() {
             window.location.href = "StudentMainPage.aspx";
             return false; 
         }
         function ClientValidation(source, arguments) {
             var CustomValidator1 = document.getElementById("CustomValidator1");
             var value = document.getElementById("txtStudentName").value;
             var patrn = /^[a-zA-Z]+$/;
             if (value == "") {
                 arguments.IsValid = false;
                 CustomValidator1.innerText = "Please input name";
             }
             else if (value.length > 10) {
                 arguments.IsValid = false;
                 CustomValidator1.innerText = " The length of studentName is not great than 10";
             } else if (!patrn.exec(value)) {
                 arguments.IsValid = false;
                 CustomValidator1.innerText = " input name is just alphabet";
             }
         }
         function DropdownlistValidation(source, arguments) {
             if (document.getElementById("ddlClassName").value == "Please Select"
                ) {
                 arguments.IsValid = false;
             } else {
                 arguments.IsValid = true;
             }
         }
     </script>
     <style type="text/css"">
       .design
       {
           height:50px;
           width:150px;
       }
     </style>
    <fieldset  style="width:717px; height: 269px;"100px">
    <legend>Student</legend>
    <table>
    <tr class="design">
       <td>
            <asp:Label runat="server" ID="labStudentName" Text="Student Name" 
            Font-Underline="False" Font-Bold="True" ></asp:Label>
       </td>
        <td>
    <asp:TextBox runat="server" ID="txtStudentName" ClientIDMode="Static" Width="208px" ></asp:TextBox>
        </td>
        <td>  
 <asp:CustomValidator ID="CustomValidator1" runat="server" ClientIDMode="Static" ErrorMessage="Student Name can not be null" ForeColor="Red"
                    ControlToValidate="txtStudentName"  ValidateEmptyText="true" ClientValidationFunction="ClientValidation"></asp:CustomValidator>
        </td>
    </tr>
    <tr class="design">
        <td>
        <asp:Label runat="server" ID="LabStudentGender" Text="Student Gender" 
            Font-Underline="False" Font-Bold="True" ></asp:Label>
        </td>
        <td>
         <asp:RadioButton ID="RadioBtnMale" runat="server" Text="Male" 
            GroupName="GenderGroup" Checked="true" />
        &nbsp;&nbsp;
        <asp:RadioButton ID="RadioBtnFemale" runat="server" 
            Text="Female" GroupName="GenderGroup"  />
        </td>
        <td>
        </td>
    </tr>
        <tr class="design">
        <td>
         <asp:Label runat="server" ID="LabClassName" Text="Class Name" 
            Font-Underline="False" Font-Bold="True" ></asp:Label>
        </td>
        <td>
         <asp:DropDownList ID="ddlClassName" runat="server" ClientIDMode="Static"  Width="207px">
            <asp:ListItem Value="Please Select" >Please Select</asp:ListItem>
        </asp:DropDownList>
        </td>
        <td>
            <asp:CustomValidator ID="CustomValidator2" runat="server" 
                ClientValidationFunction="DropdownlistValidation" 
                ControlToValidate="ddlClassName" 
                ErrorMessage="Class Name  is not valiate" ForeColor="Red"></asp:CustomValidator>
        </td>
    </tr>
        <tr class="design">
        <td align="center">       
        <asp:Button ID="BtnSave" runat="server" Text="Save" Width="63px" 
            onclick="BtnSave_Click" />   
        </td>
        <td align="center">
      <input type="button" value="Cancel"  onclick="GotoStudentMainPage();"  />   
        </td>
        <td>
        </td>
        </tr>
    </table>

    </fieldset>
    </asp:Panel> 
    </div>
</asp:Content>
